﻿using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using Aspose.Cells;
using Aspose.Cells.Rendering;

namespace Helpers
{
    public class ExcelHelper
    {
        public static List<Bitmap> ConvertToImages(string filepath)
        {
            var bmps = new List<Bitmap>();
            var book = new Workbook(filepath);
            foreach (Worksheet sheet in book.Worksheets)
            {
                var imgOptions = new ImageOrPrintOptions();
                imgOptions.ImageFormat = ImageFormat.Jpeg;
                imgOptions.OnePagePerSheet = true;
                var sr = new SheetRender(sheet, imgOptions);
                for (int i = 0; i < sr.PageCount; i++)
                {
                    bmps.Add(sr.ToImage(i));
                }
            }
            return bmps;
        }

    }
}
